package com.wzy.netty.nio;

import lombok.extern.slf4j.Slf4j;

import java.nio.ByteBuffer;

/**
 * 描述  :
 * 创建人:    Wzy
 * 创建时间: 2020-06-10  15:06
 */
@Slf4j
public class ReadOnlyBuffer {
    public static void main(String[] args) {
        ByteBuffer buffer = ByteBuffer.allocate(64);
        for (int i = 0; i < 64; i++) {
            buffer.put((byte) i);
        }

        buffer.flip();
        ByteBuffer readOnlyBuffer = buffer.asReadOnlyBuffer();
        log.info("类型:{}", readOnlyBuffer.getClass());

        while (readOnlyBuffer.hasRemaining()) {
            log.info(String.valueOf(readOnlyBuffer.get()));
        }
    }
}
